
<body style="position:relative;">


<!--内容开始-->
<div class="payment-interface w1200">
    <div class="pay-info">
        <div class="info-tit">
            <h3>选择收货地址</h3>
        </div>
        <ul class="pay-dz">

        <?php foreach ($address as $key => $value) {?>
        
            <li onclick="change(<?php echo $value['id'];?>)" class="<?php echo $value['isDefault']=='默认'?'current':'';?>">
                <h3><span class="sp1"><?php echo $value['provinceName'];?> </span><span class="sp2"><?php echo $value['cityName'];?></span>（<span class="sp3"><?php echo $value['username'];?></span> 收）</h3>
                <p><span class="sp1"><?php echo $value['address'];?></span><span class="sp2"><?php echo $value['phone'];?></span></p>
                 
            </li>
        <?php  } ?>
            <div style="clear:both;"></div>
        </ul>
        <P class="pay-xgdz">修改地址和使用新地址样式一样。</P>
        <button class="pay-xdz-btn" onclick="$('.confirmation-tanchuang').show()">使用新地址</button>
    </div>
    <div class="pay-info">
        <div class="info-tit" style="border-bottom:0;">
            <h3>订单信息</h3>
        </div>
    </div>
    <div class="cart-con-info">
        <div  class="cart-con-tit" style="margin:20px 0 0px;">
            <p class="p1" style="width:400px;">
                <input type="checkbox" value="" name="hobby"></input>
                <span>商家：向东服饰专卖店</span>
            </p>
            <p class="p3" style="width:145px;">规格</p>
            <p class="p4" style="width:130px;">数量</p>
            <p class="p8" style="width:75px;">运费</p>
            <p class="p5">单价（元）</p>
            <p class="p6" style="width:173px;">金额（元）</p>
        </div>

        <?php foreach ($orderList as $key => $value) {
            ?>
            
      
        <div class="info-mid">
            <div class="mid-tu f-l"  style="width:180px;">
                <a href="#"><img  width="140" height="100"  src="<?php echo Url::base(); ?>uploads/<?php   echo $value['mainpic']; ?>" /></a>
            </div>
            <div class="mid-font f-l" style="margin-right:40px;">
                <a href="#"><?php   echo $value['title']; ?></a>
            </div>
            <div class="mid-guige1 f-l"  style="margin-left: 100px;">
                <?php  foreach ($value['specificationsList'] as $skey => $svalue) {
                    echo '<p>'.$svalue.'</p>';
                } ?>
                
            </div>
            <div class="mid-sl f-l" style="">
                <a href="javascript:changeNumber();" class="sl-left">-</a>
                <input type="text" id="size" value="<?php echo $value['number'];?>" attr="<?php echo $value['productId'];?>" style="width:50px;" />
                <a href="javascript:changeNumber();" class="sl-right">+</a>
            </div>
            <p class="mid-yunfei f-l" onclick="$('#ttt').show()">费用详细</p>
            <p class="mid-dj f-l" style="margin-left: -10px;">¥ <?php echo $value['price'];?></p>
            <p class="mid-je f-l" style="width:70px;">¥ <?php echo $value['price']*$value['number'];?></p>

            <div style="clear:both;"></div>
        </div>
        <?php    } ?>
        <div class="info-heji">

            <p class="f-r">店铺合计(含运费)：<span id="money">¥<?php echo $sizeMoney;?></span></p>
            <h3 class="f-r">订单号：<?php echo $orderId;?></h3>
        </div>
        <div class="info-tijiao">
            <p class="f-r" name=""> <select id="express" onchange="selectUpdate(this)">
                    <?php foreach($express as $key => $value){ ?>
                    <option value="<?php  echo $value['id']; ?>"><?php  echo $value['name']; ?></option>
                    <?php  }?>
                </select></p>
            <p class="p1">实付款：<span id="money">¥<?php echo $sizeMoney;?></span></p>
            <button class="btn" <?php  if( $orderList[0]['orderstatus']=='订单已支付'||$orderList[0]['orderstatus']=='订单已完成'){echo 'readonly=readonly';}?> ><?php echo $orderList[0]['orderstatus'];?></button>
        </div>
    </div>
</div>
<script>

    var orderId = '<?php echo $orderId;?>';
    var addressId = null;
    var json ={};
    function selectUpdate(){
        json['orderId'] = orderId;

        json.expressId = $('#express').val();
        $.ajax({
                                data:json,
                                type: 'POST',
                                url: '<?php echo Url::base(); ?>index.php/product/updateExpress',
                                success: function(data){
                                    console.log(data)
                                     $("span[id='money']").html('¥'+data)
                                   
                                } ,
                                dataType: "json"

                            });
    }
    function changeNumber(){
        var count = 0;
        var productList = new Array();
        var numberList = new Array();
        $("input[id='size']").each(function($value){
            numberList[count]=($(this).val())
            productList[count] =$(this).attr("attr");

            count ++;
        })
        json = {number:numberList.join(',')}
        json['product'] =productList.join(',')
        json['orderId'] = orderId;

        

          $.ajax({
                                data:json,
                                type: 'POST',
                                url: '<?php echo Url::base(); ?>index.php/product/updateNumber',
                                success: function(data){
                                    console.log(data)
                                     $("span[id='money']").html('¥'+data)
                                   
                                } ,
                                dataType: "json"

                            });
    }
    function change(id){
        json.addressId = id;

        json.orderId = orderId;
          $.ajax({
                                data:json,
                                type: 'POST',
                                url: '<?php echo Url::base(); ?>index.php/product/updateAddress',
                                success: function(data){
                                    console.log(data)
                                     $("span[id='money']").html('¥'+data)
                                   
                                } ,
                                dataType: "json"

                            });
    }
    function countCreate(json){

    }
</script>
<!--修改地址-->
<div class="confirmation-tanchuang" xgdz2="">
    <div class="tanchuang-bg"></div>
    <div class="tanchuang-con">
        <div class="tc-title">
            <h3>新增地址</h3>
            <a href="JavaScript:;" dz-guan=""><img src="<?php echo Url::base(); ?>images/close-select-city.gif" /></a>
            <div style="clear:both;"></div>
        </div>


        <ul class="tc-con2">
            <li class="tc-li1">
                <p class="l-p">所在地区<span>*</span></p>
                <div class="xl-dz">
                    <div class="dz-left f-l">
                        <p>请选择</p>
                        <ul>

                            <?php foreach($list as $key=>$value){
                                echo '   <li  onclick="getCity('.$value['Id'].')" ><a href="#">'.$value['Name'].'</a></li>';

                            } ?>

                        </ul>
                    </div>

                    <script>
                        var province = null;
                        var city = null;
                        function citychose(id,name){
                            city = id;
                            $("#cityp").html(name)
                            $("#cityUl").hide()
                        }
                        function getCity(id){
                            province = id;
                            $.ajax({

                                type: 'POST',
                                url: '<?php echo Url::base(); ?>index.php/chinam/getCity?id='+ province,
                                success: function(data){
                                    console.log(data)
                                    for(var i = 0 ;i<data.length;i++){
                                        $("#cityUl").append('<li onclick="citychose('+data[i]['Id']+',\''+data[i]['Name']+'\')" ><a href="#" >'+data[i]['Name']+'</a></li>');
                                    }
                                } ,
                                dataType: "json"

                            });
                        }
                        function save(){
                            if(province == null){alert("请选择所在地区");return false;}
                            if(city == null){alert("请选择城市");return false;}
                            if(document.getElementById('address').value == ""){alert("请填写地址");return false;}
                            if(document.getElementById('reviceName').value==""){alert("请填写收货人姓名");return false;}
                            if($("#phone").val()==""||!/^(17[0-9]|13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/i.test($("#phone").val())){alert("请填写正确格式手机号");return false;}

                            $.ajax({
                                data:{
                                    provinceId:province,
                                    cityId:city,
                                    address:document.getElementById('address').value,
                                    username:document.getElementById('reviceName').value,
                                    phone:$("#phone").val(),
                                    isDefault:$("#isDefault").val()
                                },
                                type: 'POST',
                                url: '<?php echo Url::base(); ?>index.php/user/insertAddress',
                                success: function(data){
                                    if(data.msg ){
                                        alert("添加成功")
                                        window.location.reload();
                                    }else{
                                        alert(data.data)
                                    }
                                } ,
                                dataType: "json"

                            });
                        }
                    </script>
                    <div class="dz-right f-l">
                        <p id="cityp">请选择</p>
                        <ul id="cityUl">

                        </ul>
                    </div>
                    <div style="clear:both;"></div>
                </div>
                <div style="clear:both;"></div>
            </li>
            <li class="tc-li1">
                <p class="l-p">详细地址<span>*</span></p>
                <textarea  id="address" class="textarea1" placeholder="请如实填写您的详细信息，如街道名称、门牌号、楼层号和房间号。"></textarea>
                <div style="clear:both;"></div>
            </li>

            <li class="tc-li1">
                <p class="l-p">收货人姓名<span>*</span></p>
                <input type="text"  id="reviceName"/>
                <div style="clear:both;"></div>
            </li>

            <li class="tc-li1">
                <selpect id="isDefault"  style="display: none;">

                    <option value="默认" >默认</option>
                    <option value="未默认" selected>未默认</option>
                </selpect>
                <div style="clear:both;"></div>
            </li>
            <li class="tc-li1">
                <p class="l-p">联系电话<span>*</span></p>
                <input type="text" id="phone" />
                <div style="clear:both;"></div>
            </li>
        </ul>
        <button class="btn-pst2" onclick="save()">保存</button>
    </div>
</div>



<div class="confirmation-tanchuang" id="ttt" xgdz2="">
    <div class="tanchuang-bg"></div>
    <div class="tanchuang-con">
        <div class="tc-title">
            <?php echo $orderDetail; ?>
            <a href="JavaScript:;" dz-guan="" style="margin-top: 0px;"><img src="<?php echo Url::base(); ?>images/close-select-city.gif" /></a>
        

        </div>

</div>